<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        // var s = 'aaa_aa_a';
        // var r1 = /a+/g;
        // var r2 = /a+/y;
        
        // console.log(r1.exec(s));  // ["aaa"]
        // console.log(r2.exec(s));  // ["aaa"]
        // console.log(r1.exec(s));  // ["aa"]
        // console.log(r2.exec(s));  // null
        // console.log(/abc/ig.flags);  // 'gi'
        // console.log(/abc/ig.source);  // "abc"

        const string = 'test1test2test3';
        const regex = /t(e)(st(\d?))/g;
        for (const match of string.matchAll(regex)) {
            console.log(match);
        }
    </script>
</body>
</html>